<script lang="ts" setup>
import { ref, watch, onMounted } from 'vue'
import { useRoute } from "vue-router";
import { storeToRefs } from "pinia";
import { requestSynthesizeSearchResult } from "../../utils/axiosURL"
import useSearchHistory from "../../store/searchHistory";
import indexText from "./index.json"

const { keyword_Store } = storeToRefs(useSearchHistory())
const route = useRoute()
// 路由传递的关键字
let keywords = ref<any | string>('')
// 默认路由下标
let defaultIndex = ref<number>(0)
// 监听关键字的变化
watch(keyword_Store, () => {
  keywords.value = keyword_Store
  defaultIndex.value = 0
})
// 点击改变下标
const changeIndexFn = (index: number) => {
  defaultIndex.value = index
}

</script>

<template>
  <div class="searchWrap">
    <p class="searchKeywords">{{ indexText.search }} {{ keyword_Store }}</p>
    <!-- <div class="Interested_In">
      <p class="bingoInterested">{{ indexText.bingoInteresting }}</p>
      <div class="searchInterestingBox">
        <div class="InterestingItem" v-for="item in 2">
          <div class="leftImg">
            <img src="../../assets/handsome.jpg" alt="">
          </div>
          <div class="rightDesc">
            <p>专辑: 爱如火</p>
            <p>徐佳莹</p>
          </div>
        </div>
      </div>
    </div> -->
    <div class="childNav">
      <ul class="childUL">
        <li class="childItem" v-for="(item, index) in indexText.childNav" :class="index === defaultIndex ? 'active' : ''"
          @click="changeIndexFn(index)">
          <Router-link :to="item.code">
            {{ item.name }}
          </Router-link>
        </li>
      </ul>
    </div>

    <Router-view />
  </div>
</template>

<style lang="scss" scoped>
.searchWrap {
  @extend .pageWrapSize;
  padding: 0 19px 30px 19px;
  box-sizing: border-box;

  .searchKeywords {
    line-height: 50px;
    font-family: $activeTextFont;
    color: #000;
    font-size: $font-size-lg;
  }

  .Interested_In {
    display: flex;
    justify-content: space-between;
    flex-direction: column;
    width: 100%;
    margin: 10px 0;

    .bingoInterested {
      font-size: $font-size-xs;
      color: $font_second_color;
      font-family: $activeTextFont;
    }

    .searchInterestingBox {
      display: flex;
      align-items: center;
      width: 100%;
      height: 70px;
      margin-top: 6px;

      .InterestingItem {
        display: flex;
        align-items: center;
        width: 290px;
        height: 100%;
        padding-left: 10px;
        margin-right: 10px;
        box-sizing: border-box;
        background-color: $BK_GRAY;
        border-radius: 6px;

        .leftImg {
          flex-basis: 50px;
          width: 50px;
          height: 50px;
          overflow: hidden;
          border-radius: 6px;

          img {
            width: 100%;
            height: 100%;
          }
        }

        .rightDesc {
          flex: 1;
          margin-left: 8px;
          font-size: $font-size-sm;
          font-family: $activeTextFont;
          color: $font_second_color;
        }
      }
    }
  }

  .childNav {
    width: 100%;
    height: 50px;

    .childUL {
      display: flex;
      align-items: center;
      width: 100%;
      height: 100%;

      .childItem {
        position: relative;
        font-family: $textFont;
        line-height: 30px;
        margin-right: 30px;
      }

      .active {
        position: relative;
        font-size: $font-size-lg;
        font-family: $activeTextFont;

        &::after {
          content: "";
          position: absolute;
          left: 0;
          bottom: 0;
          width: 100%;
          height: 3px;
          @include background_color('bk_color');
        }
      }
    }
  }
}
</style>
